# -*- coding:utf-8 -*-
# @FileName  :t16.py
# @Time      :2021/7/15 16:03
import base64
import io
import sys
import execjs
import requests

import time
from Crypto.Util.Padding import pad
import requests
from Crypto.Cipher import AES, DES
from binascii import b2a_hex
from pyDes import *

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='gb18030')


def jie():
    b = str(int(time.time())) + '000'
    m = str(int(str(int(time.time())) + '000') * 1234)
    m1 = str(int(str(int(time.time())) + '000') * 4321)
    key = m.encode()
    cryptor = AES.new(key=key, mode=AES.MODE_CBC, iv=m1.encode())
    cryptor1 = AES.new(key=key, mode=AES.MODE_CBC, iv=m1.encode())
    data = cryptor.encrypt(pad(b.encode(), AES.block_size))
    plain_text = cryptor1.decrypt(data).decode()
    # print(b2a_hex(data))
    # print(plain_text)
    return (b2a_hex(data)).upper()


def jie2():
    with open('t6.js', 'r', encoding='gbk') as f:
        jstext = f.read()
    ctx = execjs.compile(jstext)
    result = ctx.call('gete')
    return result


def main(m, f):
    global num
    kv = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36',
        'cookie': 'session=522e3a87-5a23-4499-9fd1-ac1d903b822b.vlyG9RKkIYR8qFRdyEl__ZQYgig; v={}'.format(jie2()),
        'Referer': 'http://spider.wangluozhe.com/challenge/6'
    }
    par = {
        'page': f,
        'count': 10,
        # '_signature': m
    }
    r = requests.post(f'http://spider.wangluozhe.com/challenge/api/6', headers=kv, data=par).json()
    print(r)
    print(kv['cookie'].split(';')[1])
    try:
        for i in r['data']:
            num += i['value']
    except:
        return main(m, f)


if __name__ == "__main__":
    num = 0
    for i in range(1, 101):
        main(1, i)
        # input('123')
    print(num)
